﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SoftHotel.Models;
using System.Web.Security;

namespace SoftHotel.Controllers
{
    public class LoginController : Controller
    {
        public ActionResult Index()
        {
            return View();
        }
        [HttpPost]
        public ActionResult Index(Usuario model)
        {
            if (ModelState.IsValid)
            {

                if (model.nombre == "admin" && model.password == "admin")
                {
                    FormsAuthentication.SetAuthCookie(model.nombre, true);
                    return RedirectToAction("index", "Home");
                }
                {
                    ModelState.AddModelError("", "Nombre de usuario o contraseña invalido");
                }
            }
            return View();

        }

        public ActionResult LogOff()
        {
            FormsAuthentication.SignOut();

            return RedirectToAction("Index", "Login");
        }

    }
}
